﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Reflection;
using log4net;
using log4net.Config;
using AnyOffice.Components;

namespace AnyOffice
{
    public class Global : System.Web.HttpApplication
    {
        private static ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
        private IContainer container;

       

        public Global()
        {
           
            this.container = new Container();
        }

        protected void Application_Start(object sender, EventArgs e)
        {
            XmlConfigurator.Configure();
            ConfigManager.Update();
            ApplicationCache.Update();
            InterfaceCache.Update();      

        }
        public override string GetVaryByCustomString(HttpContext context, string custom)
        {
            string str = "default";
            if (custom.ToLower() == "theme")
            {
                try
                {
                    if (base.User.Identity.IsAuthenticated)
                    {
                        str = new UserCache().Theme.ToString();
                    }
                }
                catch (Exception exception)
                {
                    if (log.IsErrorEnabled)
                    {
                        log.Error("", exception);
                    }
                }
            }
            return str;
        }       

        protected void Session_Start(object sender, EventArgs e)
        {

        }

        protected void Application_BeginRequest(object sender, EventArgs e)
        {

        }

        protected void Application_AuthenticateRequest(object sender, EventArgs e)
        {

        }

        protected void Application_Error(object sender, EventArgs e)
        {

        }

        protected void Session_End(object sender, EventArgs e)
        {

        }

        protected void Application_End(object sender, EventArgs e)
        {

        }
    }
}